<html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Chapter 15. Code Coverage Analysis</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <link rel="stylesheet" href="docbook.css" tppabs="http://www.phpunit.de/manual/current/en/docbook.css" type="text/css"></link>
</head>
<body>

<div id="header">
  <h1>PHPUnit Manual</h1>

  <ul>
<li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.4/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.4/en/index.html'" tppabs="http://www.phpunit.de/manual/3.4/en/index.html">PHPUnit 3.4 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.3/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.3/en/index.html'" tppabs="http://www.phpunit.de/manual/3.3/en/index.html" class="active">PHPUnit 3.3 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.2/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.2/en/index.html'" tppabs="http://www.phpunit.de/manual/3.2/en/index.html">PHPUnit 3.2 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.1/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.1/en/index.html'" tppabs="http://www.phpunit.de/manual/3.1/en/index.html">PHPUnit 3.1 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.0/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.0/en/index.html'" tppabs="http://www.phpunit.de/manual/3.0/en/index.html">PHPUnit 3.0 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/2.3/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/2.3/en/index.html'" tppabs="http://www.phpunit.de/manual/2.3/en/index.html">PHPUnit 2.3 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.3/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.3/ja/index.html'" tppabs="http://www.phpunit.de/manual/3.3/ja/index.html">PHPUnit 3.3 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.2/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.2/ja/index.html'" tppabs="http://www.phpunit.de/manual/3.2/ja/index.html">PHPUnit 3.2 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.1/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.1/ja/index.html'" tppabs="http://www.phpunit.de/manual/3.1/ja/index.html">PHPUnit 3.1 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.0/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.0/ja/index.html'" tppabs="http://www.phpunit.de/manual/3.0/ja/index.html">PHPUnit 3.0 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/2.3/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/2.3/ja/index.html'" tppabs="http://www.phpunit.de/manual/2.3/ja/index.html">PHPUnit 2.3 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/2.3/de/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/2.3/de/index.html'" tppabs="http://www.phpunit.de/manual/2.3/de/index.html">PHPUnit 2.3 <span><small>German</small></span></a></li>
  </ul>
</div>
<div class="colmask leftmenu">
  <div class="colleft">
    <div class="col1">
      <table border="0" width="100%">
        <tr>
          <td align="left"><a accesskey="p" href="behaviour-driven-development.html" tppabs="http://www.phpunit.de/manual/current/en/behaviour-driven-development.html">Prev</a></td>
          <td align="right"><a accesskey="n" href="other-uses-for-tests.html" tppabs="http://www.phpunit.de/manual/current/en/other-uses-for-tests.html">Next</a></td>
        </tr>
      </table>
<div class="chapter" title="Chapter 15. Code Coverage Analysis"><div class="titlepage"><div><div><h2 class="title"><a id="code-coverage-analysis"></a>Chapter 15. Code Coverage Analysis</h2></div></div></div><p>
    You have learned how to use unit tests to test your code. But how do you
    test your tests? How do you find code that is not yet tested -- or, in
    other words, not yet <span class="emphasis"><em>covered</em></span> by a test? How do you
    measure testing completeness? All these questions are answered by a
    practice called Code Coverage Analysis. Code Coverage Analysis gives you
    an insight into what parts of the production code are executed when the
    tests are run.
  </p><p>
    <a id="id2567952" class="indexterm"></a>

    PHPUnit's Code Coverage Analysis utilizes the statement coverage
    functionality provided by the <a class="ulink" href="javascript:if(confirm('http://www.xdebug.org/  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.xdebug.org/'" tppabs="http://www.xdebug.org/" target="_top">Xdebug</a>
    extension. An example of what statement coverage means is that if there is
    a method with 100 lines of code, and only 75 of these lines are actually
    executed when tests are being run, then the method is considered to have a
    code coverage of 75 percent.
  </p><p>
    Let us generate a code coverage report for the <code class="literal">BankAccount</code>
    class from <a class="xref" href="test-driven-development.html#test-driven-development.bankaccount-example.examples.BankAccount2.php" tppabs="http://www.phpunit.de/manual/current/en/test-driven-development.html#test-driven-development.bankaccount-example.examples.BankAccount2.php" title="Example 13.3: The complete BankAccount class">Example 13.3</a>.
  </p><pre class="screen"><strong class="userinput"><code>phpunit --coverage-html ./report BankAccountTest</code></strong>
PHPUnit 3.3.0 by Sebastian Bergmann.

...

Time: 0 seconds

OK (3 tests, 3 assertions)

Generating report, this may take a moment.</pre><p>
    <a class="xref" href="code-coverage-analysis.html#code-coverage-analysis.figures.Code_Coverage.png" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.figures.Code_Coverage.png" title="Figure 15.1. Code Coverage for setBalance()">Figure 15.1</a> shows
    an excerpt from a Code Coverage report. Lines of code that were executed
    while running the tests are highlighted green, lines of code that are
    executable but were not executed are highlighted red, and "dead code" is
    highlighted orange. The number left to the actual line of code indicates
    how many tests cover that line.
  </p><div class="figure"><a id="code-coverage-analysis.figures.Code_Coverage.png"></a><p class="title"><b>Figure 15.1. Code Coverage for <code class="literal">setBalance()</code></b></p><div class="figure-contents"><div><img src="figures/Code_Coverage.png" tppabs="http://www.phpunit.de/manual/current/en/figures/Code_Coverage.png" alt="Code Coverage for setBalance()"></img></div></div></div><br class="figure-break"></br><p>
    Clicking on the line number of a covered line will open a panel (see
    <a class="xref" href="code-coverage-analysis.html#code-coverage-analysis.figures.Code_Coverage2.png" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.figures.Code_Coverage2.png" title="Figure 15.2. Panel with information on covering tests">Figure 15.2</a>) that
    shows the test cases that cover this line.
  </p><div class="figure"><a id="code-coverage-analysis.figures.Code_Coverage2.png"></a><p class="title"><b>Figure 15.2. Panel with information on covering tests</b></p><div class="figure-contents"><div><img src="figures/Code_Coverage2.png" tppabs="http://www.phpunit.de/manual/current/en/figures/Code_Coverage2.png" alt="Panel with information on covering tests"></img></div></div></div><br class="figure-break"></br><p>
    The code coverage report for our <code class="literal">BankAccount</code> example
    shows that we do not have any tests yet that call the
    <code class="literal">setBalance()</code>, <code class="literal">depositMoney()</code>, and
    <code class="literal">withdrawMoney()</code> methods with legal values.
    <a class="xref" href="code-coverage-analysis.html#code-coverage-analysis.examples.BankAccountTest.php" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.examples.BankAccountTest.php" title="Example 15.1: Test missing to achieve complete code coverage">Example 15.1</a>
    shows a test that can be added to the <code class="literal">BankAccountTest</code>
    test case class to completely cover the <code class="literal">BankAccount</code>
    class.
  </p><div class="example"><a id="code-coverage-analysis.examples.BankAccountTest.php"></a><p class="title"><b>Example 15.1: Test missing to achieve complete code coverage</b></p><div class="example-contents"><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'PHPUnit/Framework.php'</span><span class="keyword">;</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'BankAccount.php'</span><span class="keyword">;</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">BankAccountTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;...</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testDepositWithdrawMoney</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">depositMoney</span><span class="keyword">(</span><span class="default">1</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">1</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">withdrawMoney</span><span class="keyword">(</span><span class="default">1</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
    <a class="xref" href="code-coverage-analysis.html#code-coverage-analysis.figures.Code_Coverage3.png" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.figures.Code_Coverage3.png" title="Figure 15.3. Code Coverage for setBalance() with additional test">Figure 15.3</a> shows
    the code coverage of the <code class="literal">setBalance()</code> method with the
    additional test.
  </p><div class="figure"><a id="code-coverage-analysis.figures.Code_Coverage3.png"></a><p class="title"><b>Figure 15.3. Code Coverage for <code class="literal">setBalance()</code> with additional test</b></p><div class="figure-contents"><div><img src="figures/Code_Coverage3.png" tppabs="http://www.phpunit.de/manual/current/en/figures/Code_Coverage3.png" alt="Code Coverage for setBalance() with additional test"></img></div></div></div><br class="figure-break"></br><div class="section" title="Specifying Covered Methods"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="code-coverage-analysis.specifying-covered-methods"></a>Specifying Covered Methods</h2></div></div></div><p>
      <a id="id2569151" class="indexterm"></a>
      <a id="id2569156" class="indexterm"></a>

      The <code class="literal">@covers</code> annotation (see
      <a class="xref" href="code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods.tables.annotations" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods.tables.annotations" title="Table 15.1. Supported annotations for specifying covered methods">Table 15.1</a>)
      can be used in the test code to specify which method(s) a test method
      wants to test. If provided, only the code coverage information for the
      specified method(s) will be considered.
      <a class="xref" href="code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods.examples.BankAccountTest.php" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods.examples.BankAccountTest.php" title="Example 15.2: Tests that specify which method they want to cover">Example 15.2</a>
      shows an example.
    </p><div class="example"><a id="code-coverage-analysis.specifying-covered-methods.examples.BankAccountTest.php"></a><p class="title"><b>Example 15.2: Tests that specify which method they want to cover</b></p><div class="example-contents"><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'PHPUnit/Framework.php'</span><span class="keyword">;</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'BankAccount.php'</span><span class="keyword">;</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">BankAccountTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="default">$ba</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">setUp</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">BankAccount</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">/**</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@covers&nbsp;BankAccount::getBalance</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testBalanceIsInitiallyZero</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">/**</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@covers&nbsp;BankAccount::withdrawMoney</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testBalanceCannotBecomeNegative</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">try</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">withdrawMoney</span><span class="keyword">(</span><span class="default">1</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">catch</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">BankAccountException</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">fail</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">/**</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@covers&nbsp;BankAccount::depositMoney</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testBalanceCannotBecomeNegative2</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">try</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">depositMoney</span><span class="keyword">(</span><span class="keyword">-</span><span class="default">1</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">catch</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">BankAccountException</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">fail</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">/**</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@covers&nbsp;BankAccount::getBalance</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@covers&nbsp;BankAccount::depositMoney</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@covers&nbsp;BankAccount::withdrawMoney</span><br /><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testDepositWithdrawMoney</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">depositMoney</span><span class="keyword">(</span><span class="default">1</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">1</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">withdrawMoney</span><span class="keyword">(</span><span class="default">1</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">ba</span><span class="keyword">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><div class="table"><a id="code-coverage-analysis.specifying-covered-methods.tables.annotations"></a><p class="title"><b>Table 15.1. Supported annotations for specifying covered methods</b></p><div class="table-contents"><table summary="Supported annotations for specifying covered methods" border="1"><colgroup><col></col><col></col></colgroup><thead><tr><th align="left">Annotation</th><th align="left">Description</th></tr></thead><tbody><tr><td align="left"><code class="literal">@covers ClassName::methodName</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers the specified method.</code></td></tr><tr><td align="left"><code class="literal">@covers ClassName</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers all methods of a given class.</code></td></tr><tr><td align="left"><code class="literal">@covers ClassName&lt;extended&gt;</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers all methods of a given class and its parent class(es) and interface(s).</code></td></tr><tr><td align="left"><code class="literal">@covers ClassName::&lt;public&gt;</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers all public methods of a given class.</code></td></tr><tr><td align="left"><code class="literal">@covers ClassName::&lt;protected&gt;</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers all protected methods of a given class.</code></td></tr><tr><td align="left"><code class="literal">@covers ClassName::&lt;private&gt;</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers all private methods of a given class.</code></td></tr><tr><td align="left"><code class="literal">@covers ClassName::&lt;!public&gt;</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers all methods of a given class that are not public.</code></td></tr><tr><td align="left"><code class="literal">@covers ClassName::&lt;!protected&gt;</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers all methods of a given class that are not protected.</code></td></tr><tr><td align="left"><code class="literal">@covers ClassName::&lt;!private&gt;</code></td><td align="left"><code class="literal">Specifies that the annotated test method covers all methods of a given class that are not private.</code></td></tr></tbody></table></div></div><br class="table-break"></br></div><div class="section" title="Ignoring Code Blocks"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="code-coverage-analysis.ignoring-code-blocks"></a>Ignoring Code Blocks</h2></div></div></div><p>
      <a id="id2569445" class="indexterm"></a>
      <a id="id2569451" class="indexterm"></a>
      <a id="id2569457" class="indexterm"></a>

      Sometimes you have blocks of code that you cannot test and that you may
      want to ignore during code coverage analysis. PHPUnit lets you do this
      using the <code class="literal">@codeCoverageIgnoreStart</code> and
      <code class="literal">@codeCoverageIgnoreEnd</code> annotations as shown in
      <a class="xref" href="code-coverage-analysis.html#code-coverage-analysis.ignoring-code-blocks.examples.Sample.php" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.ignoring-code-blocks.examples.Sample.php" title="Example 15.3: Using the @codeCoverageIgnoreStart and @codeCoverageIgnoreEnd annotations">Example 15.3</a>.
    </p><div class="example"><a id="code-coverage-analysis.ignoring-code-blocks.examples.Sample.php"></a><p class="title"><b>Example 15.3: Using the <code class="literal">@codeCoverageIgnoreStart</code> and <code class="literal">@codeCoverageIgnoreEnd</code> annotations</b></p><div class="example-contents"><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">Sample</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;...</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;@codeCoverageIgnoreStart</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">doSomethingElse</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;@codeCoverageIgnoreEnd</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;...</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      The lines of code between the <code class="literal">@codeCoverageIgnoreStart</code>
      and <code class="literal">@codeCoverageIgnoreEnd</code> annotations are counted as
      executed (if they are executable) and will not be highlighted.
    </p></div><div class="section" title="Including and Excluding Files"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="code-coverage-analysis.including-excluding-files"></a>Including and Excluding Files</h2></div></div></div><p>
      <a id="id2569544" class="indexterm"></a>
      <a id="id2569549" class="indexterm"></a>
      <a id="id2569555" class="indexterm"></a>
      <a id="id2569562" class="indexterm"></a>

      By default, all sourcecode files that contain at least one line of code
      that has been executed (and only these files) are included in the report.
      You can configure the sourcecode files that are included in the report
      using the <code class="literal">PHPUnit_Util_Filter</code> API (see
      <a class="xref" href="code-coverage-analysis.html#code-coverage-analysis.including-excluding-files.tables.filter-api" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.including-excluding-files.tables.filter-api" title="Table 15.2. The PHPUnit_Util_Filter API">Table 15.2</a>).
    </p><div class="table"><a id="code-coverage-analysis.including-excluding-files.tables.filter-api"></a><p class="title"><b>Table 15.2. The <code class="literal">PHPUnit_Util_Filter</code> API</b></p><div class="table-contents"><table summary="The PHPUnit_Util_Filter API" border="1"><colgroup><col></col><col></col></colgroup><thead><tr><th align="left">Method</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left"><code class="literal">void addDirectoryToFilter(string $directory)</code></td><td align="left">Adds all files from a directory that are suffixed with <code class="literal">.php</code> to the blacklist (recursively).</td></tr><tr><td align="left"><code class="literal">void addDirectoryToFilter(string $directory, string $suffix)</code></td><td align="left">Adds all files from a directory that are suffixed with <code class="literal">$suffix</code> to the blacklist (recursively).</td></tr><tr><td align="left"><code class="literal">void addFileToFilter(string $filename)</code></td><td align="left">Adds a file to the blacklist.</td></tr><tr><td align="left"><code class="literal">void removeDirectoryFromFilter(string $directory)</code></td><td align="left">Removes all files from a directory that are suffixed with <code class="literal">.php</code> from the blacklist (recursively).</td></tr><tr><td align="left"><code class="literal">void removeDirectoryFromFilter(string $directory, string $suffix)</code></td><td align="left">Removes all files from a directory that are suffixed with <code class="literal">$suffix</code> from the blacklist (recursively).</td></tr><tr><td align="left"><code class="literal">void removeFileFromFilter(string $filename)</code></td><td align="left">Removes a file from the blacklist.</td></tr><tr><td align="left"><code class="literal">void addDirectoryToWhitelist(string $directory)</code></td><td align="left">Adds all files from a directory that are suffixed with <code class="literal">.php</code> to the whitelist (recursively).</td></tr><tr><td align="left"><code class="literal">void addDirectoryToWhitelist(string $directory, string $suffix)</code></td><td align="left">Adds all files from a directory that are suffixed with <code class="literal">$suffix</code> to the whitelist (recursively).</td></tr><tr><td align="left"><code class="literal">void addFileToWhitelist(string $filename)</code></td><td align="left">Adds a file to the whitelist.</td></tr><tr><td align="left"><code class="literal">void removeDirectoryFromWhitelist(string $directory)</code></td><td align="left">Removes all files from a directory that are suffixed with <code class="literal">.php</code> from the whitelist (recursively).</td></tr><tr><td align="left"><code class="literal">void removeDirectoryFromWhitelist(string $directory, string $suffix)</code></td><td align="left">Removes all files from a directory that are suffixed with <code class="literal">$suffix</code> from the whitelist (recursively).</td></tr><tr><td align="left"><code class="literal">void removeFileFromWhitelist(string $filename)</code></td><td align="left">Removes a file from the whitelist.</td></tr></tbody></table></div></div><br class="table-break"></br><p>
      The blacklist is pre-filled with all sourcecode files of PHPUnit itself
      and the tests. When the whitelist is empty (default), blacklisting is used.
      When the whitelist is not empty, whitelisting is used.
    </p></div></div>
      <table border="0" width="100%">
        <tr>
          <td align="left"><a accesskey="p" href="behaviour-driven-development.html" tppabs="http://www.phpunit.de/manual/current/en/behaviour-driven-development.html">Prev</a></td>
          <td align="right"><a accesskey="n" href="other-uses-for-tests.html" tppabs="http://www.phpunit.de/manual/current/en/other-uses-for-tests.html">Next</a></td>
        </tr>
      </table>
    </div>
    <div class="col2">
<dl><dt><span class="chapter"><a href="automating-tests.html" tppabs="http://www.phpunit.de/manual/current/en/automating-tests.html">1. 自动化测试</a></span></dt><dt><span class="chapter"><a href="goals.html" tppabs="http://www.phpunit.de/manual/current/en/goals.html">2. PHPUnit的目标</a></span></dt><dt><span class="chapter"><a href="installation.html" tppabs="http://www.phpunit.de/manual/current/en/installation.html">3. 安装PHPUnit</a></span></dt><dt><span class="chapter"><a href="writing-tests-for-phpunit.html" tppabs="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html">4. 为PHPUnit编写测试</a></span></dt><dd><dl><dt><span class="section"><a href="writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers" tppabs="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers">Data Providers</a></span></dt><dt><span class="section"><a href="writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions" tppabs="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions">Testing Exceptions</a></span></dt><dt><span class="section"><a href="writing-tests-for-phpunit.html#writing-tests-for-phpunit.errors" tppabs="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.errors">Testing PHP Errors</a></span></dt></dl></dd><dt><span class="chapter"><a href="textui.html" tppabs="http://www.phpunit.de/manual/current/en/textui.html">5. The Command-Line Test Runner</a></span></dt><dt><span class="chapter"><a href="fixtures.html" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html">6. Fixtures</a></span></dt><dd><dl><dt><span class="section"><a href="fixtures.html#fixtures.more-setup-than-teardown" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html#fixtures.more-setup-than-teardown">More setUp() than tearDown()</a></span></dt><dt><span class="section"><a href="fixtures.html#fixtures.variations" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html#fixtures.variations">Variations</a></span></dt><dt><span class="section"><a href="fixtures.html#fixtures.sharing-fixture" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html#fixtures.sharing-fixture">Sharing Fixture</a></span></dt><dt><span class="section"><a href="fixtures.html#fixtures.global-state" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html#fixtures.global-state">Global State</a></span></dt></dl></dd><dt><span class="chapter"><a href="organizing-tests.html" tppabs="http://www.phpunit.de/manual/current/en/organizing-tests.html">7. Organizing Tests</a></span></dt><dd><dl><dt><span class="section"><a href="organizing-tests.html#organizing-tests.filesystem" tppabs="http://www.phpunit.de/manual/current/en/organizing-tests.html#organizing-tests.filesystem">Composing a Test Suite Using the Filesystem</a></span></dt><dt><span class="section"><a href="organizing-tests.html#organizing-tests.xml-configuration" tppabs="http://www.phpunit.de/manual/current/en/organizing-tests.html#organizing-tests.xml-configuration">Composing a Test Suite Using XML Configuration</a></span></dt><dt><span class="section"><a href="organizing-tests.html#organizing-tests.testsuite" tppabs="http://www.phpunit.de/manual/current/en/organizing-tests.html#organizing-tests.testsuite">Using the TestSuite Class</a></span></dt></dl></dd><dt><span class="chapter"><a href="testcase-extensions.html" tppabs="http://www.phpunit.de/manual/current/en/testcase-extensions.html">8. TestCase Extensions</a></span></dt><dd><dl><dt><span class="section"><a href="testcase-extensions.html#testcase-extensions.output" tppabs="http://www.phpunit.de/manual/current/en/testcase-extensions.html#testcase-extensions.output">Testing Output</a></span></dt><dt><span class="section"><a href="testcase-extensions.html#testcase-extensions.performance" tppabs="http://www.phpunit.de/manual/current/en/testcase-extensions.html#testcase-extensions.performance">Testing Performance</a></span></dt></dl></dd><dt><span class="chapter"><a href="database.html" tppabs="http://www.phpunit.de/manual/current/en/database.html">9. Database Testing</a></span></dt><dd><dl><dt><span class="section"><a href="database.html#database.datasets" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets">Data Sets</a></span></dt><dd><dl><dt><span class="section"><a href="database.html#database.datasets.flatxml" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets.flatxml">Flat XML Data Set</a></span></dt><dt><span class="section"><a href="database.html#database.datasets.xml" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets.xml">XML Data Set</a></span></dt><dt><span class="section"><a href="database.html#database.datasets.csv" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets.csv">CSV Data Set</a></span></dt><dt><span class="section"><a href="database.html#database.datasets.replacement" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets.replacement">Replacement Data Set</a></span></dt></dl></dd><dt><span class="section"><a href="database.html#database.operations" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.operations">Operations</a></span></dt><dt><span class="section"><a href="database.html#database.bestpractices" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.bestpractices">Database Testing Best Practices</a></span></dt></dl></dd><dt><span class="chapter"><a href="incomplete-and-skipped-tests.html" tppabs="http://www.phpunit.de/manual/current/en/incomplete-and-skipped-tests.html">10. Incomplete and Skipped Tests</a></span></dt><dd><dl><dt><span class="section"><a href="incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.incomplete-tests" tppabs="http://www.phpunit.de/manual/current/en/incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.incomplete-tests">Incomplete Tests</a></span></dt><dt><span class="section"><a href="incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.skipping-tests" tppabs="http://www.phpunit.de/manual/current/en/incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.skipping-tests">Skipping Tests</a></span></dt></dl></dd><dt><span class="chapter"><a href="test-doubles.html" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html">11. Test Doubles</a></span></dt><dd><dl><dt><span class="section"><a href="test-doubles.html#test-doubles.stubs" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs">Stubs</a></span></dt><dt><span class="section"><a href="test-doubles.html#test-doubles.mock-objects" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mock-objects">Mock Objects</a></span></dt><dt><span class="section"><a href="test-doubles.html#test-doubles.mocking-the-filesystem" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mocking-the-filesystem">Mocking the Filesystem</a></span></dt></dl></dd><dt><span class="chapter"><a href="testing-practices.html" tppabs="http://www.phpunit.de/manual/current/en/testing-practices.html">12. Testing Practices</a></span></dt><dd><dl><dt><span class="section"><a href="testing-practices.html#testing-practices.during-development" tppabs="http://www.phpunit.de/manual/current/en/testing-practices.html#testing-practices.during-development">During Development</a></span></dt><dt><span class="section"><a href="testing-practices.html#testing-practices.during-debugging" tppabs="http://www.phpunit.de/manual/current/en/testing-practices.html#testing-practices.during-debugging">During Debugging</a></span></dt></dl></dd><dt><span class="chapter"><a href="test-driven-development.html" tppabs="http://www.phpunit.de/manual/current/en/test-driven-development.html">13. Test-Driven Development</a></span></dt><dd><dl><dt><span class="section"><a href="test-driven-development.html#test-driven-development.bankaccount-example" tppabs="http://www.phpunit.de/manual/current/en/test-driven-development.html#test-driven-development.bankaccount-example">BankAccount Example</a></span></dt></dl></dd><dt><span class="chapter"><a href="behaviour-driven-development.html" tppabs="http://www.phpunit.de/manual/current/en/behaviour-driven-development.html">14. Behaviour-Driven Development</a></span></dt><dd><dl><dt><span class="section"><a href="behaviour-driven-development.html#behaviour-driven-development.bowlinggame-example" tppabs="http://www.phpunit.de/manual/current/en/behaviour-driven-development.html#behaviour-driven-development.bowlinggame-example">BowlingGame Example</a></span></dt></dl></dd><dt><span class="chapter"><a href="code-coverage-analysis.html" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html" class="active">15. Code Coverage Analysis</a></span></dt><dd><dl><dt><span class="section"><a href="code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods">Specifying Covered Methods</a></span></dt><dt><span class="section"><a href="code-coverage-analysis.html#code-coverage-analysis.ignoring-code-blocks" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.ignoring-code-blocks">Ignoring Code Blocks</a></span></dt><dt><span class="section"><a href="code-coverage-analysis.html#code-coverage-analysis.including-excluding-files" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.including-excluding-files">Including and Excluding Files</a></span></dt></dl></dd><dt><span class="chapter"><a href="other-uses-for-tests.html" tppabs="http://www.phpunit.de/manual/current/en/other-uses-for-tests.html">16. Other Uses for Tests</a></span></dt><dd><dl><dt><span class="section"><a href="other-uses-for-tests.html#other-uses-for-tests.agile-documentation" tppabs="http://www.phpunit.de/manual/current/en/other-uses-for-tests.html#other-uses-for-tests.agile-documentation">Agile Documentation</a></span></dt><dt><span class="section"><a href="other-uses-for-tests.html#other-uses-for-tests.cross-team-tests" tppabs="http://www.phpunit.de/manual/current/en/other-uses-for-tests.html#other-uses-for-tests.cross-team-tests">Cross-Team Tests</a></span></dt></dl></dd><dt><span class="chapter"><a href="skeleton-generator.html" tppabs="http://www.phpunit.de/manual/current/en/skeleton-generator.html">17. Skeleton Generator</a></span></dt><dd><dl><dt><span class="section"><a href="skeleton-generator.html#skeleton-generator.test" tppabs="http://www.phpunit.de/manual/current/en/skeleton-generator.html#skeleton-generator.test">Generating a Test Case Class Skeleton</a></span></dt><dt><span class="section"><a href="skeleton-generator.html#skeleton-generator.class" tppabs="http://www.phpunit.de/manual/current/en/skeleton-generator.html#skeleton-generator.class">Generating a Class Skeleton from a Test Case Class</a></span></dt></dl></dd><dt><span class="chapter"><a href="javascript:if(confirm('http://www.phpunit.de/manual/current/en/selenium.html  \n\nļδ Teleport Pro ȡأΪ ޷ȡãȡغĿֹ̫ͣ졣  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/current/en/selenium.html'" tppabs="http://www.phpunit.de/manual/current/en/selenium.html">18. PHPUnit and Selenium</a></span></dt><dd><dl><dt><span class="section"><a href="javascript:if(confirm('http://www.phpunit.de/manual/current/en/selenium.html  \n\nļδ Teleport Pro ȡأΪ ޷ȡãȡغĿֹ̫ͣ졣  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/current/en/selenium.html#selenium.selenium-rc'" tppabs="http://www.phpunit.de/manual/current/en/selenium.html#selenium.selenium-rc">Selenium RC</a></span></dt><dt><span class="section"><a href="javascript:if(confirm('http://www.phpunit.de/manual/current/en/selenium.html  \n\nļδ Teleport Pro ȡأΪ ޷ȡãȡغĿֹ̫ͣ졣  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/current/en/selenium.html#selenium.seleniumtestcase'" tppabs="http://www.phpunit.de/manual/current/en/selenium.html#selenium.seleniumtestcase">PHPUnit_Extensions_SeleniumTestCase</a></span></dt></dl></dd><dt><span class="chapter"><a href="logging.html" tppabs="http://www.phpunit.de/manual/current/en/logging.html">19. Logging</a></span></dt><dd><dl><dt><span class="section"><a href="logging.html#logging.xml" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.xml">Test Results (XML)</a></span></dt><dt><span class="section"><a href="logging.html#logging.tap" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.tap">Test Results (TAP)</a></span></dt><dt><span class="section"><a href="logging.html#logging.json" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.json">Test Results (JSON)</a></span></dt><dt><span class="section"><a href="logging.html#logging.codecoverage" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.codecoverage">Code Coverage (XML)</a></span></dt><dt><span class="section"><a href="logging.html#logging.database" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.database">Test Database</a></span></dt></dl></dd><dt><span class="chapter"><a href="build-automation.html" tppabs="http://www.phpunit.de/manual/current/en/build-automation.html">20. Build Automation</a></span></dt><dd><dl><dt><span class="section"><a href="build-automation.html#build-automation.ant" tppabs="http://www.phpunit.de/manual/current/en/build-automation.html#build-automation.ant">Apache Ant</a></span></dt><dt><span class="section"><a href="build-automation.html#build-automation.maven" tppabs="http://www.phpunit.de/manual/current/en/build-automation.html#build-automation.maven">Apache Maven</a></span></dt><dt><span class="section"><a href="build-automation.html#build-automation.phing" tppabs="http://www.phpunit.de/manual/current/en/build-automation.html#build-automation.phing">Phing</a></span></dt></dl></dd><dt><span class="chapter"><a href="continuous-integration.html" tppabs="http://www.phpunit.de/manual/current/en/continuous-integration.html">21. Continuous Integration</a></span></dt><dd><dl><dt><span class="section"><a href="continuous-integration.html#continuous-integration.atlassian-bamboo" tppabs="http://www.phpunit.de/manual/current/en/continuous-integration.html#continuous-integration.atlassian-bamboo">Atlassian Bamboo</a></span></dt><dt><span class="section"><a href="continuous-integration.html#continuous-integration.cruisecontrol" tppabs="http://www.phpunit.de/manual/current/en/continuous-integration.html#continuous-integration.cruisecontrol">CruiseControl</a></span></dt><dt><span class="section"><a href="continuous-integration.html#continuous-integration.phpUnderControl" tppabs="http://www.phpunit.de/manual/current/en/continuous-integration.html#continuous-integration.phpUnderControl">phpUnderControl</a></span></dt></dl></dd><dt><span class="chapter"><a href="api.html" tppabs="http://www.phpunit.de/manual/current/en/api.html">22. PHPUnit API</a></span></dt><dd><dl><dt><span class="section"><a href="api.html#api.overview" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.overview">Overview</a></span></dt><dt><span class="section"><a href="api.html#api.assert" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert">PHPUnit_Framework_Assert</a></span></dt><dd><dl><dt><span class="section"><a href="api.html#api.assert.assertArrayHasKey" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertArrayHasKey"><code class="literal">assertArrayHasKey()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertClassHasAttribute" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertClassHasAttribute"><code class="literal">assertClassHasAttribute()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertClassHasStaticAttribute" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertClassHasStaticAttribute"><code class="literal">assertClassHasStaticAttribute()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertContains" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertContains"><code class="literal">assertContains()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertContainsOnly" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertContainsOnly"><code class="literal">assertContainsOnly()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertEqualXMLStructure" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertEqualXMLStructure"><code class="literal">assertEqualXMLStructure()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertEquals" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertEquals"><code class="literal">assertEquals()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertFalse" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertFalse"><code class="literal">assertFalse()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertFileEquals" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertFileEquals"><code class="literal">assertFileEquals()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertFileExists" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertFileExists"><code class="literal">assertFileExists()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertGreaterThan" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertGreaterThan"><code class="literal">assertGreaterThan()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertGreaterThanOrEqual" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertGreaterThanOrEqual"><code class="literal">assertGreaterThanOrEqual()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertLessThan" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertLessThan"><code class="literal">assertLessThan()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertLessThanOrEqual" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertLessThanOrEqual"><code class="literal">assertLessThanOrEqual()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertNotNull" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertNotNull"><code class="literal">assertNotNull()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertObjectHasAttribute" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertObjectHasAttribute"><code class="literal">assertObjectHasAttribute()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertRegExp" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertRegExp"><code class="literal">assertRegExp()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertSame" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertSame"><code class="literal">assertSame()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertSelectCount" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertSelectCount"><code class="literal">assertSelectCount()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertSelectEquals" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertSelectEquals"><code class="literal">assertSelectEquals()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertSelectRegExp" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertSelectRegExp"><code class="literal">assertSelectRegExp()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertStringEqualsFile" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertStringEqualsFile"><code class="literal">assertStringEqualsFile()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertTag" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertTag"><code class="literal">assertTag()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertThat" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertThat"><code class="literal">assertThat()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertTrue" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertTrue"><code class="literal">assertTrue()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertType" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertType"><code class="literal">assertType()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertXmlFileEqualsXmlFile" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertXmlFileEqualsXmlFile"><code class="literal">assertXmlFileEqualsXmlFile()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertXmlStringEqualsXmlFile" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertXmlStringEqualsXmlFile"><code class="literal">assertXmlStringEqualsXmlFile()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertXmlStringEqualsXmlString" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertXmlStringEqualsXmlString"><code class="literal">assertXmlStringEqualsXmlString()</code></a></span></dt></dl></dd><dt><span class="section"><a href="api.html#api.test" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.test">PHPUnit_Framework_Test</a></span></dt><dt><span class="section"><a href="api.html#api.testcase" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.testcase">PHPUnit_Framework_TestCase</a></span></dt><dt><span class="section"><a href="api.html#api.testsuite" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.testsuite">PHPUnit_Framework_TestSuite</a></span></dt><dt><span class="section"><a href="api.html#api.testresult" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.testresult">PHPUnit_Framework_TestResult</a></span></dt><dt><span class="section"><a href="api.html#api.package-structure" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.package-structure">Package Structure</a></span></dt></dl></dd><dt><span class="chapter"><a href="extending-phpunit.html" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html">23. Extending PHPUnit</a></span></dt><dd><dl><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestCase" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestCase">Subclass PHPUnit_Framework_TestCase</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.Assert" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.Assert">Assert Classes</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Extensions_TestDecorator" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Extensions_TestDecorator">Subclass PHPUnit_Extensions_TestDecorator</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Framework_Test" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_Test">Implement PHPUnit_Framework_Test</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestResult" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestResult">Subclass PHPUnit_Framework_TestResult</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener">Implement PHPUnit_Framework_TestListener</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.TestRunner" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.TestRunner">New Test Runner</a></span></dt></dl></dd><dt><span class="appendix"><a href="appendixes.assertions.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.assertions.html">A. Assertions</a></span></dt><dt><span class="appendix"><a href="appendixes.configuration.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html">B. The XML Configuration File</a></span></dt><dd><dl><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.phpunit" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.phpunit">PHPUnit</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.testsuite" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.testsuite">Test Suite</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.groups" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.groups">Groups</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.blacklist-whitelist" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.blacklist-whitelist">Including and Excluding Files for Code Coverage</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.logging" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.logging">Logging</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables">Setting PHP INI settings, Constants and Global Variables</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.selenium-rc" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.selenium-rc">Configuring Browsers for Selenium RC</a></span></dt></dl></dd><dt><span class="appendix"><a href="appendixes.index.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.index.html">C. Index</a></span></dt><dd><dl><dt><span class="index"><a href="appendixes.index.html#appendixes.index.index" tppabs="http://www.phpunit.de/manual/current/en/appendixes.index.html#appendixes.index.index"></a></span></dt></dl></dd><dt><span class="appendix"><a href="appendixes.bibliography.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.bibliography.html">D. Bibliography</a></span></dt><dt><span class="appendix"><a href="appendixes.copyright.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.copyright.html">E. Copyright</a></span></dt></dl>
    </div>
  </div>
</div>
<div id="footer">
  <p><a href="appendixes.copyright.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.copyright.html">Copyright</a> &copy; 2005-2009 <a href="javascript:if(confirm('http://sebastian-bergmann.de/  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://sebastian-bergmann.de/'" tppabs="http://sebastian-bergmann.de/">Sebastian Bergmann</a>.</p>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www./");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-68261-7");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>

